<template>
  <view class="content">
    <uni-forms ref="form1" labelWidth="80px" :border="true" class="bg-white margin-top-lg">
      <uni-forms-item name="deal1" label="处理单位" class="margin-left margin-right flexcenter">
        <view class="flexrowflexend">
          <text class="text-gray text-df margin-right-xs">{{ form.deptName }}</text>
        </view>
      </uni-forms-item>
    </uni-forms>
    <uni-forms ref="form" :value="form" labelWidth="80px" :border="true" class="bg-white margin-top">
      <uni-forms-item name="deal2" label="处理结果" class="margin-left margin-right flexrowcenter ">
        <view class="flexrowflexend">
          <text class="text-gray text-df margin-right-xs text-right" style="width: 380rpx">{{ form.remark }}</text>
        </view>
      </uni-forms-item>
      <uni-forms-item name="deal3" label="处理照片" class="margin-left margin-right" >
        <view class="flexrowflexend">
					<upload v-model="form.handleImg" :isResponse="false" :maxCount="0" :deletable="false"></upload>
        </view>
      </uni-forms-item>
      <uni-forms-item name="deal4" label="处理时间" class="margin-left margin-right flexrowcenter">
        <view class="flexrowflexend">
          <text class="text-gray text-df margin-right-xs">{{ dayjs(form.handleTime).format('YYYY-MM-DD HH:mm:ss') }}</text>
        </view>
      </uni-forms-item>
      <uni-forms-item name="deal5" label="解决状态" class="margin-left margin-right flexrowcenter">
        <view class="flexrowflexend">
          <text class="text-gray text-df margin-right-xs">{{ form.handleStatic ? '已解决' : '未解决' }}</text>
        </view>
      </uni-forms-item>
      <uni-forms-item name="deal6" label="处理人" class="margin-left margin-right flexrowcenter">
        <view class="flexrowflexend">
          <text class="text-gray text-df margin-right-xs">{{ form.handleUserName }}</text>
        </view>
      </uni-forms-item>
    </uni-forms>
    <view class="button-container">
      <button type="primary" class="button" @click="modify">修改</button>
    </view>
  </view>
</template>
<script>
import dayjs from "dayjs";
import { handleGet } from "@/api/police/index"
export default {
  data() {
    return {
      dayjs: dayjs,
      dealres: '',
      form: {
      },
      paramsdetail: {}
    }
  },
  onLoad(query) {
    // const {id} = query || {}
    const {
				data
			} = query || {}
    this.paramsdetail = JSON.parse(data);
    this.getData()
  },
  onReady(){
    this.$refs.form.setRules(this.rules)
  },
  methods: {
    getData() {
      handleGet({id: this.paramsdetail.id}).then(({data})=>{
        console.log('res>>',data)
        this.form = data
      })
    },
    gotopreviewImage(){
      uni.previewImage({
        urls:[
            'https://img-blog.csdnimg.cn/9f2860af5a9a48e38d13b5651cf4faac.jpeg',
            'https://img-home.csdnimg.cn/images/20230817060237.png'
        ]
      })

    },
    savebtn() {
      this.$refs.form.validate().then(res => {
        // updateUserPwd(this.user.oldPassword, this.user.newPassword).then(response => {
        //   this.$modal.msgSuccess("修改成功")
        // })
      })
    },
    modify() {
      uni.navigateTo({
        url: `/pages/police/police-deal/police-deal?data=` + encodeURIComponent(JSON.stringify(this.form))
      })
      uni.$once('refresh-handle-update', ()=>{
        this.getData()
      })
    },
    openActionSheet() {
      let itemInfo = ['item1', 'item2', 'item3', 'item4']
      uni.showActionSheet({
        title: '选择',
        itemList: itemInfo,
        itemColor: "#0048ff",
        success: (e) => {
          console.log(e.tapIndex);
          uni.showToast({
            title: "点击了第" + e.tapIndex + "个选项",
            icon: "none"
          })
        },
        fail: (e) => {
          console.log(e);
        }
      })
    }
  }
}
</script>
<style scoped>
.content {
  height: 100%;
  padding-bottom: calc(var(--window-bottom) + 20px);

}

.image {
  width: 50px;
  /*background-color: red;*/
  height: 50px;
  margin-left: 10px;

}

.button-container {
  margin-top:  300rpx;
  display: flex;
  height: 50px;
}

.button {
  flex: 1;
  margin-right: 10px;
  margin-left: 10px;
  height: 100%;
  text-align: center;
  line-height: 50px;
  font-size: 16px;
  border-radius: 5px;
  color: #fff;
}

</style>
